package com.team.ai.service;

import com.team.ai.entity.Administrator;
import com.team.ai.entity.ResultEntity;
import com.team.ai.entity.User;
import com.team.ai.mapper.AdminiMapper;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class AdminiService {
    @Resource
    AdminiMapper adminiMapper;
    public Administrator login(String name, String pwd){
        try{
            return adminiMapper.login(name,pwd);
        }catch (Exception e){

            return  null;
        }
    }
    public String insert(String name,String pwd,String phone,String email,int age){
        try{
            return ResultEntity.success(adminiMapper.insert(name, pwd, phone, email, age)) ;
        }catch (Exception e){
            e.printStackTrace();

            return  ResultEntity.fail(-10005);
        }
    }

    public String delete(int id){
        try{
            return ResultEntity.success(adminiMapper.delete(id)) ;
        }catch (Exception e){
            e.printStackTrace();

            return  ResultEntity.fail(-10005);
        }
    }
    public String update(String name,String pwd,String phone,String email,int age,int id){
        try{
            return ResultEntity.success(adminiMapper.update(name, pwd, phone, email, age, id)) ;
        }catch (Exception e){
            e.printStackTrace();

            return  ResultEntity.fail(-10005);
        }
    }
    public String selectList(){
        try{
            return ResultEntity.success(adminiMapper.selectList()) ;
        }catch (Exception e){
            e.printStackTrace();

            return  ResultEntity.fail(-10005);
        }
    }
    public String selectByPrimaryKey(int id){
        try{
            return ResultEntity.success(adminiMapper.selectByPrimaryKey(id)) ;
        }catch (Exception e){
            e.printStackTrace();

            return  ResultEntity.fail(-10005);
        }
    }

}
